package com.hehui.partimejob.fragment.category_child;

import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hehui.partimejob.PartTimeDetailActivity;
import com.hehui.partimejob.R;
import com.hehui.partimejob.adapter.MyRecyclerViewAdapter;
import com.hehui.partimejob.fragment.BaseFragment;
import com.hehui.partimejob.service.inter.OnStateChangeListener;
import com.hehui.partimejob.service.model.Bean.PartTimeBean;
import com.hehui.partimejob.service.model.Bean.RecTaskItemBean;
import com.hehui.partimejob.service.model.PartTimeModel;
import com.hehui.partimejob.service.model.RecTaskItemModel;
import com.scwang.smart.refresh.header.ClassicsHeader;

import java.util.List;

public class OneAreaFragment extends BaseFragment implements OnStateChangeListener {
    private TextView todayTask;
    private TextView goToSee;
    private RecyclerView rv;

    private ClassicsHeader header;


    @Override
    public void init() {
        getNav().hide();

        todayTask = (TextView) findViewById(R.id.todayTask);
        goToSee = (TextView) findViewById(R.id.goToSee);
        header = (ClassicsHeader) findViewById(R.id.header);
        rv = (RecyclerView) findViewById(R.id.rv);

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_category_child_one;
    }

    @Override
    protected void begin(Bundle bundle) {
        PartTimeModel partTimeModel = new PartTimeModel(A);
        partTimeModel.setListener(this);
        partTimeModel.loadPartTimeTask();
    }

    @Override
    public void OnStateChanged(String tag, List data) {
        switch (tag) {
            case "PartTimeModel":
                rv.setAdapter(new MyRecyclerViewAdapter<PartTimeBean>(data, R.layout.rv_part_time_item) {
                    @Override
                    protected void handleData(InnerHolder holder, PartTimeBean item) {
                        holder.setText(R.id.title, item.getTitle())
                                .setText(R.id.coin, getString(R.string.mostHight)+item.getCoin() + getString(R.string.coin))
                                .setText(R.id.ddl, item.getDdl())
                                .setText(R.id.surplus, getString(R.string.surplus) + item.getSurplus() + getString(R.string.fen))
                                .setImgDrawable(R.id.icon, A.getDrawable(R.drawable.questionnaire));
                    }

                });
                break;
            default:
                break;
        }
    }
}
